package com.bifrost.entity;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the PRODUCT database table.
 */
@Entity
@Table(name = "PRODUCT",indexes = {
        @Index(name = "CATEGORY_INDEX",columnList = "CATEGORY",unique = false),
        @Index(name = "MERCHANT_ID_INDEX",columnList = "MERCHANT_ID",unique = false),
        @Index(name = "EXTERNAL_ID_INDEX",columnList = "EXTERNAL_ID",unique = false)
}
)
@NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p")
public class Product extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PRODUCT_ID", unique = true, nullable = false)
    private Long productId;

    @Column(name = "CAN_PREORDER")
    private Boolean canPreorder = Boolean.FALSE;

    @Column(name = "CANONICAL_URL", length = 255)
    private String canonicalUrl;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "DEFAULT_SKU_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private ProductSku defaultSku;

    @Column(name = "EXTERNAL_ID", length = 64)
    private String externalId;

    @Column(name = "FEATURED_PRODUCT")
    private Boolean featuredProduct = Boolean.FALSE;

    @Column(name = "IS_ARCHIVED")
    private Boolean archived = Boolean.FALSE;

    @Column(name = "IS_AVAILABLE")
    private Boolean available = Boolean.TRUE;

    @Column(name = "MERCHANT_ID", nullable = false)
    private Long merchantId;

    @Column(name = "META_DESC", length = 255)
    private String metaDesc;

    @Column(name = "META_TITLE", length = 255)
    private String metaTitle;

    @Column(name = "PRODUCT_MANUFACTURER", length = 255)
    private String productManufacturer;

    @Column(name = "PRODUCT_NAME", length = 100)
    private String productName;

    @Column(name = "PRODUCT_VIRTUAL")
    private Boolean productVirtual = Boolean.FALSE;

    @Column(name = "SORT_ORDER")
    private Integer sortOrder =1;

    @Column(name = "BONUS_POINTS_RATE", precision = 11)
    private Integer bonusPointsRate =0;

    @Column(name = "AUDIT_STATUS")//审核状态：READY_FOR_SALE(待上架销售)、ON_SALE_AUDITING(上架审核中)、ON_SALE(已上架)、SOLD_OUT_AUDTING(下架)、REJECT_SALE_AUDITING（驳回上架）
    private String auditStatus = "READY_FOR_SALE";

    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ProductOptionValue> productOptionValues;

    //bi-directional many-to-one association to OrderBundleItem
    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<OrderBundleItem> orderBundleItems;

    //bi-directional many-to-one association to ProductBrand
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PRODUCT_BRAND_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private ProductBrand productBrand;

    @Column(name = "PRODUCT_TYPE")
    private String productType;

    @Column(name = "EXTERNAL_CATEGORY")
    private String externalCcategory;

    //bi-directional many-to-one association to ProductAttribute
    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ProductAttribute> productAttributes;

    //bi-directional many-to-one association to ProductCategory
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CATEGORY", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Category productCategory;

    //bi-directional many-to-one association to ProductDigital
    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ProductDigital> productDigitals;

    //bi-directional many-to-one association to ProductOptionXref
    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ProductOptionXref> productOptionXrefs;

    //bi-directional many-to-one association to ProductReview
    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ProductReview> productReviews;

    //bi-directional many-to-one association to ProductSku
    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ProductSku> productSkus;

    //bi-directional many-to-one association to SkuBundleItem
    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<SkuBundleItem> skuBundleItems;

    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<PromotionSku> promotionSkus;

    @OneToMany(mappedBy = "product")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<PlanItem> planItems;

    @OneToMany(mappedBy = "productSku")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<PlanCusomer> planCusomers;

    public Product() {
    }

    public Long getProductId() {
        return this.productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Boolean getCanPreorder() {
        return this.canPreorder;
    }

    public void setCanPreorder(Boolean canPreorder) {
        this.canPreorder = canPreorder;
    }

    public String getCanonicalUrl() {
        return this.canonicalUrl;
    }

    public void setCanonicalUrl(String canonicalUrl) {
        this.canonicalUrl = canonicalUrl;
    }

    public ProductSku getDefaultSku() {
        return this.defaultSku;
    }

    public void setDefaultSku(ProductSku defaultSku) {
        this.defaultSku = defaultSku;
    }

    public String getExternalId() {
        return this.externalId;
    }

    public void setExternalId(String externalId) {
        this.externalId = externalId;
    }

    public Boolean getFeaturedProduct() {
        return this.featuredProduct;
    }

    public void setFeaturedProduct(Boolean featuredProduct) {
        this.featuredProduct = featuredProduct;
    }

    public Boolean isArchived() {
        return this.archived;
    }

    public void setArchived(Boolean isArchived) {
        this.archived = isArchived;
    }

    public Boolean isAvailable() {
        return this.available;
    }

    public void setAvailable(Boolean isAvailable) {
        this.available = isAvailable;
    }

    public Long getMerchantId() {
        return this.merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public String getMetaDesc() {
        return this.metaDesc;
    }

    public void setMetaDesc(String metaDesc) {
        this.metaDesc = metaDesc;
    }

    public String getMetaTitle() {
        return this.metaTitle;
    }

    public void setMetaTitle(String metaTitle) {
        this.metaTitle = metaTitle;
    }

    public String getProductManufacturer() {
        return this.productManufacturer;
    }

    public void setProductManufacturer(String productManufacturer) {
        this.productManufacturer = productManufacturer;
    }

    public String getProductName() {
        return this.productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public Boolean getProductVirtual() {
        return this.productVirtual;
    }

    public void setProductVirtual(Boolean productVirtual) {
        this.productVirtual = productVirtual;
    }

    public int getSortOrder() {
        return this.sortOrder;
    }

    public void setSortOrder(int sortOrder) {
        this.sortOrder = sortOrder;
    }

    public Integer getBonusPointsRate() {
        return bonusPointsRate;
    }

    public void setBonusPointsRate(Integer bonusPointsRate) {
        this.bonusPointsRate = bonusPointsRate;
    }

    public List<OrderBundleItem> getOrderBundleItems() {
        return this.orderBundleItems;
    }

    public void setOrderBundleItems(List<OrderBundleItem> orderBundleItems) {
        this.orderBundleItems = orderBundleItems;
    }

    public OrderBundleItem addOrderBundleItem(OrderBundleItem orderBundleItem) {
        getOrderBundleItems().add(orderBundleItem);
        orderBundleItem.setProduct(this);

        return orderBundleItem;
    }

    public OrderBundleItem removeOrderBundleItem(OrderBundleItem orderBundleItem) {
        getOrderBundleItems().remove(orderBundleItem);
        orderBundleItem.setProduct(null);

        return orderBundleItem;
    }

    public ProductBrand getProductBrand() {
        return this.productBrand;
    }

    public void setProductBrand(ProductBrand productBrand) {
        this.productBrand = productBrand;
    }

    public String getProductType() {
        return this.productType;
    }

    public void setProductType(String productType) {
        this.productType = productType;
    }

    public List<ProductAttribute> getProductAttributes() {
        return this.productAttributes;
    }

    public void setProductAttributes(List<ProductAttribute> productAttributes) {
        this.productAttributes = productAttributes;
    }

    public ProductAttribute addProductAttribute(ProductAttribute productAttribute) {
        getProductAttributes().add(productAttribute);
        productAttribute.setProduct(this);

        return productAttribute;
    }

    public ProductAttribute removeProductAttribute(ProductAttribute productAttribute) {
        getProductAttributes().remove(productAttribute);
        productAttribute.setProduct(null);

        return productAttribute;
    }

    public Category getProductCategory() {
        return productCategory;
    }

    public void setProductCategory(Category productCategory) {
        this.productCategory = productCategory;
    }

    public List<ProductDigital> getProductDigitals() {
        return this.productDigitals;
    }

    public void setProductDigitals(List<ProductDigital> productDigitals) {
        this.productDigitals = productDigitals;
    }

    public ProductDigital addProductDigital(ProductDigital productDigital) {
        getProductDigitals().add(productDigital);
        productDigital.setProduct(this);

        return productDigital;
    }

    public ProductDigital removeProductDigital(ProductDigital productDigital) {
        getProductDigitals().remove(productDigital);
        productDigital.setProduct(null);

        return productDigital;
    }

    public List<ProductOptionXref> getProductOptionXrefs() {
        return this.productOptionXrefs;
    }

    public void setProductOptionXrefs(List<ProductOptionXref> productOptionXrefs) {
        this.productOptionXrefs = productOptionXrefs;
    }

    public ProductOptionXref addProductOptionXref(ProductOptionXref productOptionXref) {
        getProductOptionXrefs().add(productOptionXref);
        productOptionXref.setProduct(this);

        return productOptionXref;
    }

    public ProductOptionXref removeProductOptionXref(ProductOptionXref productOptionXref) {
        getProductOptionXrefs().remove(productOptionXref);
        productOptionXref.setProduct(null);

        return productOptionXref;
    }

    public List<ProductReview> getProductReviews() {
        return this.productReviews;
    }

    public void setProductReviews(List<ProductReview> productReviews) {
        this.productReviews = productReviews;
    }

    public ProductReview addProductReview(ProductReview productReview) {
        getProductReviews().add(productReview);
        productReview.setProduct(this);

        return productReview;
    }

    public ProductReview removeProductReview(ProductReview productReview) {
        getProductReviews().remove(productReview);
        productReview.setProduct(null);

        return productReview;
    }

    public List<ProductSku> getProductSkus() {
        return this.productSkus;
    }

    public void setProductSkus(List<ProductSku> productSkus) {
        this.productSkus = productSkus;
    }

    public ProductSku addProductSkus(ProductSku productSkus) {
        getProductSkus().add(productSkus);
        productSkus.setProduct(this);

        return productSkus;
    }

    public ProductSku removeProductSkus(ProductSku productSkus) {
        getProductSkus().remove(productSkus);
        productSkus.setProduct(null);

        return productSkus;
    }

    public List<SkuBundleItem> getSkuBundleItems() {
        return this.skuBundleItems;
    }

    public void setSkuBundleItems(List<SkuBundleItem> skuBundleItems) {
        this.skuBundleItems = skuBundleItems;
    }

    public SkuBundleItem addSkuBundleItem(SkuBundleItem skuBundleItem) {
        getSkuBundleItems().add(skuBundleItem);
        skuBundleItem.setProduct(this);

        return skuBundleItem;
    }

    public SkuBundleItem removeSkuBundleItem(SkuBundleItem skuBundleItem) {
        getSkuBundleItems().remove(skuBundleItem);
        skuBundleItem.setProduct(null);

        return skuBundleItem;
    }

    public List<ProductOptionValue> getProductOptionValues() {
        return productOptionValues;
    }

    public void setProductOptionValues(List<ProductOptionValue> productOptionValues) {
        this.productOptionValues = productOptionValues;
    }

    public ProductOptionValue addProductOptionValue(ProductOptionValue productOptionValue){
        getProductOptionValues().add(productOptionValue);
        productOptionValue.setProduct(this);
        return productOptionValue;
    }

    public ProductOptionValue removeProductOptionValue(ProductOptionValue productOptionValue){
        getProductOptionValues().remove(productOptionValue);
        productOptionValue.setProduct(null);
        return productOptionValue;
    }

    public String getExternalCcategory() {
        return externalCcategory;
    }

    public void setExternalCcategory(String externalCcategory) {
        this.externalCcategory = externalCcategory;
    }

    public List<PromotionSku> getPromotionSkus() {
        return promotionSkus;
    }

    public void setPromotionSkus(List<PromotionSku> promotionSkus) {
        this.promotionSkus = promotionSkus;
    }

    public String getAuditStatus() {
        return auditStatus;
    }

    public void setAuditStatus(String auditStatus) {
        this.auditStatus = auditStatus;
    }
}